package statistics;

import java.util.List;

import javax.swing.JFrame;

import org.jfree.chart.ChartFactory;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.PiePlot3D;
import org.jfree.data.general.PieDataset;
import org.jfree.data.time.TimeSeries;
import org.jfree.util.Rotation;

public class GUIStatistics extends JFrame {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	List<PopulationStatistics> populationList;

	public GUIStatistics(List<PopulationStatistics> populationList) {
		super("SubSymbolic AI - Plotting");
		this.populationList = populationList;
		init();
	}

	public void updateList(PopulationStatistics population) {
		// TODO
	}

	public void init() {
		String chartTitle = "Title";
		// This will create the dataset
		// PieDataset dataset = createDataset();
		// based on the dataset we create the chart
		// JFreeChart chart = createChart(dataset, chartTitle);
		// we put the chart into a panel
		// ChartPanel chartPanel = new ChartPanel(chart);
		// default size
		// chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
		// add it to our application
		// setContentPane(chartPanel);

	}

	// private PieDataset createDataset() {
	// DefaultPieDataset result = new DefaultPieDataset();
	// result.setValue("Linux", 29);
	// result.setValue("Mac", 20);
	// result.setValue("Windows", 51);
	// return result;
	//
	// }

	private JFreeChart createChart(PieDataset dataset, String chartTitle) {
		TimeSeries test;
		JFreeChart chart = ChartFactory.createPieChart3D(chartTitle, // chart
																		// title
				dataset, // data
				true, // include legend
				true, false);

		PiePlot3D plot = (PiePlot3D) chart.getPlot();
		plot.setStartAngle(290);
		plot.setDirection(Rotation.CLOCKWISE);
		plot.setForegroundAlpha(0.5f);
		return chart;
	}

	public static void main(String[] args) {
		GUIStatistics demo = new GUIStatistics(null);
		demo.pack();
		demo.setVisible(true);
	}
}
